package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.ext.number.smoothstep
import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.Vector4
import kotlin.jvm.JvmName
import kotlin.math.max
import kotlin.math.min


fun<T:Number> T.smoothstep(a:T,b:T) = toDouble().smoothstep(a.toDouble(),b.toDouble())

fun <T:Number,V: Vector2<T, V>> V.smoothstep(edge0: Vector2<T, *>, edge1: Vector2<T, *>) =
    create(this.x.smoothstep(edge0.x, edge1.x) + zero,
        this.y.smoothstep(edge0.y, edge1.y) + zero)

fun <T:Number,V: Vector3<T, V>> V.smoothstep(edge0: Vector3<T, *>, edge1: Vector3<T, *>) =
    create(this.x.smoothstep(edge0.x, edge1.x) + zero,
        this.y.smoothstep(edge0.y, edge1.y) + zero,
        this.z.smoothstep(edge0.z, edge1.z) + zero)

fun <T:Number,V: Vector4<T, V>> V.smoothstep(edge0: Vector4<T, *>, edge1: Vector4<T, *>) =
    create(this.x.smoothstep(edge0.x, edge1.x) + zero,
        this.y.smoothstep(edge0.y, edge1.y) + zero,
        this.z.smoothstep(edge0.z, edge1.z) + zero,
        this.w.smoothstep(edge0.w, edge1.w) + zero)

